<?php 
if(!isset($_SESSION)) 
{ 
	session_start(); 
}
ob_start();
?>
<script type="text/javascript">
function enterTable(e,value,co){
    var key = window.event ? e.keyCode : e.which;
    if (key == 13 || key == 8 || key == 46  || key == 37 || key == 39 || co == '0') {
		if(key==13){
			var i = 0;
			var j = 0;
			var listID = new Array();
		    listID = listID.concat(["iduser","idpass"]);	
			for (j = 0; j < listID.length; j++){	
				if (listID[j] == value) {	
					if (j == listID.length - 1) {
						login();
						//return false;
					}
					document.getElementById(listID[j + 1]).focus();
					document.getElementById(listID[j + 1]).select();
					return false; 
				}
			}
			
			return false;
		}else
			return true;	
    } else if ( key < 48 || key > 57 ) {
        return false;
    }
    else return true;
				
}

function login(){
	var us=document.getElementById("iduser").value;
	var ps=document.getElementById("idpass").value;
	if(us=="" || ps==""){
		alert("Vui lòng điền đầy đủ thông tin");
		if(us==""){
			document.getElementById("iduser").focus();
		}else{
			document.getElementById("idpass").focus();
		}
	}else{
		if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp2=new XMLHttpRequest();
		}else{// code for IE6, IE5
			xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp2.onreadystatechange=function(){
											  if (xmlhttp2.readyState==4 && xmlhttp2.status==200){
											    	document.getElementById("viewrs").innerHTML=xmlhttp2.responseText;
											    	var loi=document.getElementById("idloi").value;
											    	if(loi!=""){
														if(loi=="l_notlogin"){
															document.getElementById("iduser").focus();
														}else if(loi=="l_loginok"){
															alert("<?php echo $l_loginok;?>");
															window.location="index.php?vcontent=admin_searchlog_content";
														}
											    	}
											  }
		}
		xmlhttp2.open("POST","ajax/aj_admin_login.php?us="+encodeURI(us)+"&ps="+encodeURI(ps),true);
		xmlhttp2.send();
	}
}
</script>
<form action="" method="post" name="flogin" id="flogin" >
	<table border="0" style="width:100%;padding-left:200px;padding-right:200px;">
		<tr>
			<td rowspan="3" style="width:100px;padding-right:10px;" ><img src="images/user_icon.png" style="width:100px;height:100px"/></td>
			<td style="width:60px;text-align:right;"><?=$l_username?></td>
			<td ><input onkeypress="return enterTable(event,this.id,'0');" type="text" id="iduser" name="iduser" value="<?=$_REQUEST['iduser']?>"/></td>
		</tr>	
		<tr>
			<td style="width:150px;text-align:right;"><?=$l_password?></td>
			<td ><input onkeypress="return enterTable(event,this.id,'0');" type="password" id="idpass" name="idpass" value="<?=$_REQUEST['idpass']?>"/></td>
		</tr>
		<tr>
			<td></td>
			<td></td>
		</tr>
		<tr>
			<td></td>
			<td colspan="2" align="center" id="viewrs"><input type="hidden" value=""  id="idloi"/></td>
		</tr>
		<tr>
			<td></td>
			<td></td>
			<td align="center"><input onclick="login()" type="button" id="btlogin" name="btlogin" value="<?=$l_login?>" class="btnupbg btnupload" style="width:80px;"/></td>
		</tr>
	</table>
</form>
<div class="clear"></div>